package com.itany.book.service.impl;

import com.itany.exception.ManagerException;
import com.itany.mapper.ManagerMapper;
import com.itany.pojo.ManagerUser;
import com.itany.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Author：侍家宇
 * Date：2019-09-18 上午10:17
 * Description：<描述>
 */
@Service
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRED)
public class ManagerServiceImpl implements ManagerService {
    @Autowired
    ManagerMapper managerMapper;


    /**
     *后台用户登录
     * @param managerUser
     * @return
     * @throws ManagerException
     */
    @Transactional(readOnly=true)
    public ManagerUser login(ManagerUser managerUser) throws ManagerException {
       ManagerUser m = managerMapper.selectByLoginNameAndPassword(managerUser);
        if(null == m){
            throw new ManagerException("用户名或密码错误");
        }
        return m;
    }
}
